home *** CD-ROM | disk | FTP | other *** search
- Path: news.gate.net!bftsi0!joe
- From: joe@bftsi0.UUCP (Joe Foster of Borg)
- Newsgroups: comp.lang.c++
- Subject: Re: how to reposition cursor to start of line using cout?
- Message-ID: <6508@bftsi0.UUCP>
- Date: 3 Apr 96 21:54:35 GMT
- References: <nh68bie2ac.fsf@paralysys>
- Organization: Barbara Foster Tax Service, Inc.
-
- In article <nh68bie2ac.fsf@paralysys>, nasser@paralysys (Nasser Abbasi) writes:
-
- > hi,
-
- > looking at the io stream classes I can't seem to find a way
- > to move the cursor backward.
-
- > What I want to do is say display a counter (using cout), and as
- > the program runs, the counter increaes in value, and I want to
- > print the new value,
-
- > But I do not want to do this next print on a new line, I want to
- > overwrite the old one, this means I need to move the cursor to
- > start of line to be able to do this.
-
- > any one knows a way to do?
-
- > thanks!
- > Nasser
-
- Flush the output buffer and output a '\r' (ASCII 13). Example:
-
- #include <iostream.h>
-
- extern "C" long nap(long msec);
-
- main()
- {
- for (int i = 0; i < 100; i++) {
- cout << "\ri = " << i << flush;
- sleep(1);
- }
- cout << endl;
- return 0;
- }
-
- --
- Joe Foster (joe@bftsi0.gate.net or joe%bftsi0@uunet.uu.net)
- WARNING: I cannot be held responsible for the above They're coming to
- because my cats have apparently learned to type. take me away, ha ha!
-